<template>
  <div class="risk">
    <eagle-tab-page-list
      url="/DangerCheckTaskDetail/GetHiddenDangerPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="eagleTabPageList"
    >
      <eagle-cell
        class="card"
        v-for="(item, index) in list"
        :key="index"
      >
        <template v-if="active === 0">
          <div class="warn_item">
            <div @click="goToDetail(item)">
              <div class="f14">
                <div>
                  {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                </div>
              </div>

              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="20">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />{{ item.HiddenDangerArea || "暂无区域" }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />{{ item.CreateChnName }}
                </eagle-col>
                <eagle-col span="14">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ getDateTime(item.CreateDate) }}
                </eagle-col>
              </eagle-row>
            </div>
          </div>
        </template>
        <template v-if="active === 1">
          <div class="warn_item">
            <div @click="goDetail(item)">
              <div class="f14">
                <div>
                  {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                </div>
              </div>

              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="20">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />{{ item.HiddenDangerArea || "暂无区域" }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="10">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />{{ item.CreateChnName }}
                </eagle-col>
                <eagle-col span="14">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ getDateTime(item.CreateDate) }}
                </eagle-col>
              </eagle-row>

            </div>
            <eagle-divider />
            <div class="dep_sort">
              <div
                class="fr"
                @click="history(item)"
              >
                <img src="@/assets/Images/AppIcon/icon_list_edit.png" />
                审批历史
              </div>
            </div>
          </div>
        </template>
      </eagle-cell>
    </eagle-tab-page-list>
  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";

export default {
  data() {
    return {
      params: [
        {
          title: "待制定措施",
          dataType: "ToBeFormulated",
          badge: true,
        },
        {
          title: "已制定措施",
          dataType: "BeFormulated",
          badge: false,
        },
      ],
      list: [],
      active: 0,
    };
  },
  created() {},
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    getDateTime(value) {
      return getDateTime(value);
    },
    goToDetail(item) {
      this.$router.push({
        path: "/Danger/MyMeasuresToDetail",
        query: { id: item.ID },
      });
    },
    goDetail(item) {
      this.$router.push({
        path: "/Danger/DangerCheckDetailView",
        query: { id: item.ID, type: "formulated" },
      });
    },
    getFile(equipmentCode) {
      this.$router.push({
        path: "/Equipment/safetyfile",
        query: { equipmentCode: equipmentCode },
      });
    },
    // 编辑设备信息
    edit(equipmentCode) {
      this.$router.push({
        path: "/Equipment/Edit",
        query: { equipmentCode: equipmentCode },
      });
      this.$router.push("");
    },
    // 设备检验
    editCheck(equipmentCode) {
      this.$router.push({
        path: "/Equipment/editcheck",
        query: { equipmentCode: equipmentCode },
      });
    },
    history(item) {
      this.$router.push({
        path: "/Common/ApproveHistory",
        query: {
          recordID: item.ID,
          opController: "DangerCheckTaskDetail",
          operate: "corrective,formulate",
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}

.van-divider {
  margin-top: 5px;
  margin-bottom: 5px;
}
</style>
